package day07;

import java.util.Scanner;

/*需求：
        机票价格按照淡季旺季、头等舱、商务舱和经济舱收费，
        输入机票原价、月份和头等舱、商务舱或经济舱，
        其中旺季（5-10月）头等舱9折，商务舱85折，经济舱8折，
        淡季（11月到来年4月）头等舱7折，商务舱65折，经济舱6折，
        最终输出机票价格*/

public class practice3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        /*System.out.println("请输入票价，月份，舱位");
        double price = scanner.nextDouble();
        int month = scanner.nextInt();
        int type = scanner.nextInt();
        double total = calAirPrice(price, month, type);
        System.out.println("机票价格为：" + total);

    }

    public static double calAirPrice(double price, int month, int type) {
        double total=0;
        if (month > 12 || month < 1) {
            System.out.println("请重新输入月份");
            return -1;
        }
        if (type > 5 || type < 1) {
            System.out.println("请重新选择舱位");
            return -1;
        }
        if (month >= 5 && month <= 10) {
            switch (type) {
                case 1:
                total = price * 0.9;
                break;
                case 2:
                total = price * 0.85;
                break;
                case 3:
                total = price * 0.8;
                 break;
            }
        }
        if (month<=5&&month>=11){
            switch (type) {
                case 1:
                    total = price * 0.7;
                    break;
                case 2:
                    total = price * 0.65;
                    break;
                case 3:
                    total = price * 0.6;
                    break;
            }
        }
        return total;*/


        System.out.println("请依次输入原价，月份，舱位：");
        double price =scanner.nextDouble();
        int month = scanner.nextInt();
        int type=scanner.nextInt();
        double total=calAirPrice(price,month,type);
        System.out.println("总价为："+total);



    }


    public static double calAirPrice(double price,int month,int type){
        double total=0;
        if (month>12||month<1){
            System.out.println("月份输入错误");
        }
        if (type<1||type>3){
            System.out.println("舱位选择错误");
        }
        if (month>=5&&month<=10){
            switch(type){
                case 1:
                    total=price*0.9;
                    break;
                case 2:
                    total=price*0.85;
                    break;
                case 3:
                    total=price*0.8;
                    break;
            }
        }
        if (month>=11&&month<=4){
            switch(type){
                case 1:
                    total=price*0.7;
                    break;
                case 2:
                    total=price*0.65;
                    break;
                case 3:
                    total=price*0.6;
                    break;
            }

        }

        return total;
    }
}
